<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li {
            text-align: center;
            list-style-type: none;
            font-size: 30px;
            margin: 10px;
        }

        .del {
            color: red;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <ul>
        <li>
            <span>佩奇</span>
            <span class="del" title="删除">X</span>
        </li>
        <li>
            <span>乔治</span>
            <span class="del" title="删除">X</span>
        </li>
        <li>
            <span>苏溪</span>
            <span class="del" title="删除">X</span>
        </li>
        <li>
            <span>丹妮</span>
            <span class="del" title="删除">X</span>
        </li>
    </ul>
    <script>
        let delEles = document.querySelectorAll('.del');
        [...delEles].forEach((delEle) => {
            delEle.addEventListener('click', function () {
                if (confirm('确认删除吗？')) {
                    this.parentElement.remove();
                }
            });
        });
    </script>
</body>

</html>